using Assets.Scripts.GDK;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class ShopPanelItem : gdk_base_layer
	{
		public RectTransform addIcon01;

		public RectTransform addIcon02;

		public RectTransform iconInfoIcon01;

		public RectTransform iconInfoIcon02;

		public Text info;

		public RectTransform btn;

		public Text MoneyText;

		public Image iconImage;

		public GameObject adBtnBG;

		public void OnData(GameShopModel gameShopModel, Action callback)
		{
			if (gameShopModel.shopID == 950 && GameData.closeAD)
			{
				UnityEngine.Object.Destroy(base.gameObject, 0f);
				return;
			}
			info.text = gameShopModel.coin.ToString();
			MoneyText.text = "$" + gameShopModel.dollar;
			addIcon01.gameObject.SetActive(gameShopModel.addType == 1);
			float num = gdk_stringPlus.string2float(gameShopModel.addScale);
			bool flag = num > 0f;
			addIcon02.gameObject.SetActive(flag);
			if (flag)
			{
				Text component = gdk_utils.FindChild(addIcon02, "Text").GetComponent<Text>();
				component.text = "+" + (num * 100f).ToString() + "%";
			}
			iconInfoIcon01.gameObject.SetActive(gameShopModel.itype == 1);
			iconInfoIcon02.gameObject.SetActive(gameShopModel.itype == 2);
			adBtnBG.SetActive(value: false);
			if (gameShopModel.shopID == 900)
			{
				MoneyText.text = string.Empty;
				adBtnBG.SetActive(value: true);
				if (!GameManager.getFuncOpen("shopad"))
				{
					UnityEngine.Object.Destroy(base.gameObject, 0f);
					return;
				}
			}
			btn.GetComponent<Button>().onClick.AddListener(delegate
			{
				gdk_game_manager.PlaySound(AudioID.click);
				if (Application.platform == RuntimePlatform.WindowsEditor)
				{
					Debug.Log("编辑器模式下直接获得货币：" + gameShopModel.coin);
					GameManager.addCoin(gameShopModel.coin);
				}
				if (gameShopModel.shopID == 900)
				{
					Debug.Log("播放视频");
					GameManager.PlayAdvert(Advans.SHOPPLAY, "4", delegate
					{
						gdk_game_manager.log("视频完成");
						GameManager.addCoin(gameShopModel.coin);
					}, delegate
					{
						gdk_game_manager.log("广告遇到其它类型错误失败");
					}, delegate
					{
						gdk_game_manager.log("视频取消");
					}, string.Empty);
				}
				else
				{
					callback();
				}
			});
			iconImage.sprite = gdk_game_manager.loadSprite("UI/Shop/" + gameShopModel.iconName);
		}
	}
}

